package com.example.mystore.controller;

import com.example.mystore.model.Product;
import com.example.mystore.service.UserCommodityService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@RestController
@RequestMapping("/api")
public class UserCommodityController {

    @Autowired
    private UserCommodityService userCommodityService;
    @GetMapping("/hotproducts")
    public List<Product> getHotProducts() {
        return userCommodityService.getHotUserCommodities();
    }
    @GetMapping("/floorProducts/{productId}")
    public List<Product> getProductsByProductId(@PathVariable Integer productId) {
        return userCommodityService.getProductsByProductId(productId);
    }

    @GetMapping("/search")
    public List<Product> searchProductsByKeyword(@RequestParam String keyword) {
        return userCommodityService.searchProductsByKeyword(keyword);
    }
}
